package com.yugao.fintech.draper.admin.controller;

import com.yugao.fintech.draper.auth.api.TokenFeignApi;
import com.yugao.fintech.draper.core.model.ResultVO;
import com.yugao.fintech.draper.log.annotation.AuditLog;
import com.yugao.fintech.draper.log.enums.BusinessType;
import com.yugao.fintech.draper.datasource.entity.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RequiredArgsConstructor
@RestController
@Tag(name = "令牌管理")
public class TokenController {

	private final TokenFeignApi tokenFeignApi;

	@Operation(summary = "分页查询token")
	@GetMapping("/token/page")
	public ResultVO<PageResult> pageQuery(@RequestParam Map<String, Object> params) {
		return tokenFeignApi.pageQuery(params);
	}

	@Operation(summary = "删除token")
	@AuditLog(value = "强退", businessType = BusinessType.FORCE)
	@SneakyThrows
	@DeleteMapping("/token/{token}")
	public ResultVO<Void> removeToken(@PathVariable("token") String token) {
		return tokenFeignApi.removeToken(token);
	}
}
